package tutorial;

import gui.RiskGUI;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import resources.images.ImagesPath;

import com.swtdesigner.SWTResourceManager;

public class NewGame implements TutorialWindow {

	private Label hereYouAreText;
	protected Object result;
	protected Shell shell;
	protected Shell parent;
	private Tutorial tutorial;

	/**
	 * Create the dialog
	 * @param parent
	 */
	public NewGame(Shell parent, Tutorial tutorial) {
		this.parent = parent;
		this.tutorial = tutorial;
	}

	/**
	 * Open the dialog
	 * @return the result
	 */
	public void open() {
		createContents();
		shell.open();
		shell.layout();
	}

	/**
	 * Create contents of the dialog
	 */
	protected void createContents() {
		shell = new Shell(parent, SWT.DIALOG_TRIM);
		shell.addShellListener(new ShellAdapter() {
			public void shellClosed(final ShellEvent e) {
				tutorial.endTutotial();
			}
		});
		shell.setBackgroundImage(new Image(Display.getDefault(), ImagesPath.getImageStream("tutorial_background.png")));
		shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
		shell.setLocation(parent.getBounds().width,0);
		shell.setSize(219, RiskGUI.display.getClientArea().height);
		shell.setText("New Game");

		final Label welcomeToRiskLabel = new Label(shell, SWT.CENTER);
		welcomeToRiskLabel.setBounds(10, 10, 203, 119);
		welcomeToRiskLabel.setForeground(SWTResourceManager.getColor(255, 0, 0));
		welcomeToRiskLabel.setFont(SWTResourceManager.getFont("Comic Sans MS", 22, SWT.NONE));
		
		welcomeToRiskLabel.setText("Creating a game: New game");

		hereYouAreText = new Label(shell, SWT.WRAP);
		hereYouAreText.setBounds(10, 151, 193, 401);
		hereYouAreText.setText("If you want to start a fresh new game, Click on the \"new\" option under the \"Game\" menu, or use the shortcut CTRL+N. \n\nIn the openned window, write down the names of the players, mark whether they are computer or not and decide the level of complexity of each computer player. Watch out, the expert computer is really smart!\nThe first player has to be human.");
		hereYouAreText.setFont(SWTResourceManager.getFont("Comic Sans MS", 12, SWT.NONE));

		final Label label = new Label(shell, SWT.NONE);
		label.addMouseListener(new MouseAdapter() {
			public void mouseDown(final MouseEvent arg0) {
				tutorial.prvStep();
				shell.dispose();
			}
		});
		label.setToolTipText("Create game");
		label.setBackgroundImage(new Image(Display.getCurrent(), ImagesPath.getImageStream("left.gif")));
		label.setBounds(90, shell.getBounds().height-100, 58, 58);
		
		final Label label_1 = new Label(shell, SWT.NONE);
		label_1.addMouseListener(new MouseAdapter() {
			public void mouseDown(final MouseEvent arg0) {
				tutorial.nextStep();
				shell.dispose();
			}
		});
		label_1.setToolTipText("Secret mission");
		label_1.setBackgroundImage(new Image(Display.getCurrent(), ImagesPath.getImageStream("right.gif")));
		label_1.setBounds(150, shell.getBounds().height-100, 58, 58);
		//
	}

	public Shell getShell() {
		return shell;
	}

}
